class WikiAsset < ActiveRecord::Base

  # TODO: decide if should tag wiki assets
  #acts_as_taggable_on :categories
  
  validates_presence_of     :user_id
  
  validates_each :file do |record, attr, value|
    record.errors.add :file, "name must be unique. There is already a file with this name." if (WikiAsset.count(:conditions => ["file = ?", value.filename]) > 0)
  end  
  #belongs_to :user
  
  #upload_column :file,
  #              :store_dir => proc{|wiki_asset| "wiki_assets/#{wiki_asset.id}/"},
  #              :tmp_dir => proc{|user| "wiki_assets/tmp/"}

end
